package il.ac.bgu.cs.heuristics.core;

import il.ac.bgu.cs.heuristics.graph.State;
import il.ac.bgu.cs.heuristics.graph.types.IState;
import il.ac.bgu.cs.heuristics.graph.types.ISubstitution;

import java.util.Set;

//i use this class in HeuristicEngineLightIterative
public class SearchNode implements Comparable {
	private IState	subgoal					= null;
	private int		currentDistanceToGoal	= 0;
	private int		level					= 0;

	public int GetLevel() {

		return this.level;
	}

	public IState getSubgoal() {
		return subgoal;
	}

	public int getCurrentDistanceToGoal() {
		return currentDistanceToGoal;
	}

	public SearchNode(IState subgoal, int level, int currentDistanceToGoal) {
		this.subgoal = subgoal;
		this.currentDistanceToGoal = currentDistanceToGoal;
		this.level = level;
	}

	public SearchNode(Set<ISubstitution> ConstraintList, int level,
			int CurrentDistanceToGoal) {
		this.subgoal = State.createState(ConstraintList);
		this.currentDistanceToGoal = CurrentDistanceToGoal;
		this.level = level;
	}

	@Override
	public String toString() {
		return subgoal.toString() + "\ncurrentDistanceToGoal: = "
				+ currentDistanceToGoal;

	}

	public int compareTo(Object otherNode) {
		return (this.subgoal.getSubstitutions().size() * this.GetLevel())
				- ((SearchNode) otherNode).subgoal.getSubstitutions().size()
				* ((SearchNode) otherNode).GetLevel();
		// return this.subgoal.getSubstitutions().size()
		// - ((SearchNode) otherNode).subgoal.getSubstitutions().size();
	}

}
